package com.ns.core.utils.jwt;

import com.ns.core.current.config.MyConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 全局工具方法封装
 *
 * @author lw
 */
@Component
public class SystemUtil {

    public static MyConfig config;

    @Autowired
    void setMyConfig(MyConfig config) {
        SystemUtil.config = config;
    }


    /**
     * 返回md5加密后的密码，根据当前配置的salt
     * 格式为： md5(salt + userid + password)
     */
    public static String getPasswordMd5(long userId, String password) {
        return MD5Util.md5(password, config.getMd5Salt() + userId);
    }
}
